package com.store.app.activity;

import android.app.Activity;


/**
 * ProjectName: SunTechProjects
 * PackageName: com.suntech.ui.activity
 * ClassDesc: 独立的扫码界面
 * CreateUser: Corey
 * CreateDate: 2016-01-28 下午 21:21
 * UpdateUser: Administrator
 * UpdateDate: 2016-01-28 下午 21:21
 * UpdateDesc: ******
 */
public class TestScanningActivity extends Activity {

}
  /*      implements View.OnClickListener {

    private final String TAG = TestScanningActivity.class.getSimpleName();

    private SurfaceView capture_preview;
    private RelativeLayout camera_flash_btn;
    private ToggleButton tbtn_query;
    private ToggleButton tbtn_check_code;
    private ToggleButton tbtn_qr_code;
    private TextView tv_title;
    private RelativeLayout rl_help;
    private ImageView mQrLineView;

    private TranslateAnimation mAnimation;

    private SurfaceHolder mSurfaceHolder = null;


    //扫描线动画时间
    private final int DELAY_ANI_DURATION = 1500;
    private Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what){
                case 1:
                    Log.v("zyl","重新开启扫描");
                    ScanManager.getInstance().startScan();
                    break;
            }
        }
    };

    private SurfaceHolder.Callback mSurfaceHolderCallback = new SurfaceHolder.Callback() {
        @Override
        public void surfaceCreated(SurfaceHolder holder) {

            mSurfaceHolder = holder;
            initCamera();
            CameraManager.getInstance().openDriver(holder);
        }

        @Override
        public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {

        }

        @Override
        public void surfaceDestroyed(SurfaceHolder holder) {

            if (null != CameraManager.getInstance()) {
                CameraManager.getInstance().destroy();
            }
        }
    };

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        setContentView(R.layout.test_qr_scan);
        initUI();
        //设置经纬度
        ScanManager.getInstance().setLocation(114.062972, 22.569104);
        //注册扫码监听
        ScanManager.getInstance().registerScanListener(onScanListener);

        initScanLineAni();
        setScanCodeMode();
    }

    private void initScanLineAni() {

         *//*扫描线动画*//*
        if (null == mAnimation) {
            mAnimation = new TranslateAnimation(TranslateAnimation.ABSOLUTE,
                    0f,
                    TranslateAnimation.ABSOLUTE,
                    0f,
                    TranslateAnimation.RELATIVE_TO_PARENT,
                    -0.5f,
                    TranslateAnimation.RELATIVE_TO_PARENT,
                    0.5f);
            mQrLineView.setVisibility(View.VISIBLE);
            mAnimation.setDuration(DELAY_ANI_DURATION);
            mAnimation.setRepeatCount(-1);
            mAnimation.setRepeatMode(Animation.REVERSE);
            mAnimation.setInterpolator(new LinearInterpolator());
        }
        mQrLineView.setAnimation(mAnimation);
        mAnimation.startNow();
    }

    @Override
    protected void onResume() {
        super.onResume();

        if (null != CameraManager.getInstance() && null != mSurfaceHolder) {

            CameraManager.getInstance().openDriver(mSurfaceHolder);
        }
    }

    @Override
    protected void onPause() {
        super.onPause();

        if (null != CameraManager.getInstance()) {

            CameraManager.getInstance().closeDriver();
        }

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        //解除扫码监听
        ScanManager.getInstance().unRegisterScanListener(onScanListener);
    }

    @Override
    public void onClick(View v) {

        switch (v.getId()) {

            //闪光灯
            case R.id.camera_flash_btn:

                if (camera_flash_btn.isSelected()) {

                    openLightOrNot(false);
                    camera_flash_btn.setBackgroundResource(R.drawable.btn_scan_backgroud_normal);
                } else {

                    openLightOrNot(true);
                    camera_flash_btn.setBackgroundResource(R.drawable.btn_scan_backgroud_press);
                }
                break;

            //扫码查询
            case R.id.tbtn_query:

                setScanCodeMode();
                break;
            //扫码鉴伪
            case R.id.tbtn_check_code:

                setCheckCodeMode();
                break;
            //二维码/条形码
            case R.id.tbtn_qr_code:

                setScanQRCodeMode();
                break;
            case R.id.rl_help:

                //启动扫码
                ScanManager.getInstance().startScan();
                //停止扫码
                //  ScanManager.getInstance().startScan();
                break;

        }
    }

    private void initCamera() {

        if (null != CameraManager.getInstance()) {
            //CameraManager.getInstance().init();
            //CameraManager.getInstance().openDriver(surfaceHolder);
        }
    }

    private void initUI() {

        camera_flash_btn = (RelativeLayout) findViewById(R.id.camera_flash_btn);
        tbtn_query = (ToggleButton) findViewById(R.id.tbtn_query);
        tbtn_qr_code = (ToggleButton) findViewById(R.id.tbtn_qr_code);
        tbtn_check_code = (ToggleButton) findViewById(R.id.tbtn_check_code);
        tv_title = (TextView) findViewById(R.id.tv_title);
        rl_help = (RelativeLayout) findViewById(R.id.rl_help);
        mQrLineView = (ImageView) findViewById(R.id.test_capture_scan_line);

        capture_preview = (SurfaceView) findViewById(R.id.capture_preview);


        mSurfaceHolder = capture_preview.getHolder();
        mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        mSurfaceHolder.setKeepScreenOn(true);
        mSurfaceHolder.addCallback(mSurfaceHolderCallback);

        camera_flash_btn.setOnClickListener(this);
        tbtn_query.setOnClickListener(this);
        tbtn_qr_code.setOnClickListener(this);
        tbtn_check_code.setOnClickListener(this);
        rl_help.setOnClickListener(this);
    }

    *//*对闪光灯的操作*//*
    private void openLightOrNot(boolean flag) {

        if (null == CameraManager.getInstance()) {

            camera_flash_btn.setSelected(false);
            return;
        }

        if (flag && null != CameraManager.getInstance()) {

            //打开闪光灯
            CameraManager.getInstance().openLight();
            camera_flash_btn.setSelected(true);
        } else if (null != CameraManager.getInstance()) {

            //关闭闪光灯
            CameraManager.getInstance().offLight();
            camera_flash_btn.setSelected(false);
        }
    }

    *//*扫码模式（量子云码）*//*
    private void setScanCodeMode() {

        if (null != ScanManager.getInstance()) {

            //量子云码
            ScanManager.getInstance().setCodeType(CodeType.SUNTECH_CODE.value);
            //   //扫码查询
            ScanManager.getInstance().setScanType(ScanType.SCAN_CODE.value);
        }
        tbtn_query.setChecked(true);
        tbtn_qr_code.setChecked(false);
        tbtn_check_code.setChecked(false);

        tv_title.setText(getString(R.string.string_scan));

    }

    *//*鉴伪模式（量子云码）*//*
    private void setCheckCodeMode() {

        tbtn_query.setChecked(false);
        tbtn_qr_code.setChecked(false);

        tbtn_check_code.setChecked(true);


        tv_title.setText(getString(R.string.string_check_code));

        if (null != ScanManager.getInstance()) {

            //量子云码
            ScanManager.getInstance().setCodeType(CodeType.SUNTECH_CODE.value);
            //扫码鉴伪
            ScanManager.getInstance().setScanType(ScanType.CHECK_CODE.value);
        }
    }

    *//*扫码模式（二维码）*//*
    private void setScanQRCodeMode() {

        if (null != ScanManager.getInstance()) {

            //二维码/条形码
            ScanManager.getInstance().setCodeType(CodeType.QR_CODE.value);
            //扫码查询
            ScanManager.getInstance().setScanType(ScanType.SCAN_CODE.value);
        }

        tv_title.setText(getString(R.string.string_barcode_and_qrcode));
        tbtn_query.setChecked(false);
        tbtn_qr_code.setChecked(true);
        tbtn_check_code.setChecked(false);
    }


    *//**
     * 扫码结果回调监听
     *//*
    private ScanListener onScanListener = new ScanListener() {
        *//**
         *
         * @param codeType  0:量子云码 1:二维码/条形码
         * @param scanType  0:查询     1:鉴伪
         * @param data
         *//*
        @Override
        public void onScan(int codeType, int scanType, String data) {
            handler.sendEmptyMessageDelayed(1,5000);
            Log.v("zyl", "codeType: " + codeType + " scanType: " + scanType + " data:" + data);
        }
    };
}
*/